<template>
  <div class="patient-info" v-if="true">
    <div class="patient-info-inside">
      <div class="header">
        <div class="left item">
          <img alt="左侧" src="@/components/assets/images/design/1-12.webp" />
        </div>
        <div class="middle item">缴费结算</div>
        <div class="right item">
          <img alt="右侧" src="@/components/assets/images/design/1-12.webp" />
        </div>
      </div>
      <div class="patient-info-area-box">
        <el-row
          class="patient-info-area"
          v-for="(item, index) in WaitPaythefees"
          :key="index"
        >
          <el-col :span="24">
            <div class="sign">项目类型：</div>
            <div class="content">{{ item?.billType }}</div>
          </el-col>
          <el-col :span="24">
            <div class="sign">名称：</div>
            <div class="content">{{ item?.itemName }}</div>
          </el-col>
          <el-col :span="24">
            <div class="sign">单价：</div>
            <div class="content">{{ item?.itemPrice }}</div>
          </el-col>
          <el-col :span="24">
            <div class="sign">数量：</div>
            <div class="content">{{ item?.itemQty }}</div>
          </el-col>
          <el-col :span="24">
            <div class="sign colorRed">金额：</div>
            <div class="content colorRed">{{ item?.billFee }}</div>
          </el-col>
        </el-row>
        <div class="collectBox">
          <div class="conncetBox">
            您总共有 {{ WaitPaythefees.length }} 张处方单，总计金额
            {{ countMoney }}元
          </div>
        </div>
        <el-col :span="24" class="last">
          <div class="item" @click="handleSure">我要交费</div>
        </el-col>
      </div>
    </div>
  </div>
</template>

<script>
import { AndroidToWeb, buildParentApi } from "@/utils/designer/util";
let buildParent = buildParentApi();
export default {
  name: "PatientInfo",

  componentName: "PatientInfo",

  components: {},

  data() {
    return {
      countMoney: "",
    };
  },

  computed: {
    patientInfo() {
      return this.$store.getters["DRCbiz/getPatientInfo"];
    },
    WaitPaythefees() {
      let arr = [
        {
          billNo: "032920181",
          billDate: "2025/2/6 08:14:15",
          billType: "检查",
          deptCode: "261",
          deptName: "妇科综合门诊",
          doctCode: "8058",
          doctName: "陈卫民",
          productCode: "87",
          itemName: "静脉采血",
          itemSpecs: "",
          itemLiquid: "",
          itemUnits: "次",
          itemQty: "1",
          itemPrice: "580",
          billFee: "580",
          itemNo: "42417311",
          hosFeeNo: "87",
          diseaseCode: "",
          ybInfo: "",
          diseasetype: "0",
        },
        {
          billNo: "032920181",
          billDate: "2025/2/6 08:14:15",
          billType: "检查",
          deptCode: "261",
          deptName: "妇科综合门诊",
          doctCode: "8058",
          doctName: "陈卫民",
          productCode: "87",
          itemName: "静脉采血",
          itemSpecs: "",
          itemLiquid: "",
          itemUnits: "次",
          itemQty: "1",
          itemPrice: "580",
          billFee: "580",
          itemNo: "42417311",
          hosFeeNo: "87",
          diseaseCode: "",
          ybInfo: "",
          diseasetype: "0",
        },
      ];
      console.log(this.$store.getters["DRCbiz/getWaitPaythefees"]);
      let money = 0;
      arr.map((item) => {
        money += Number(item.billFee);
      });
      this.countMoney = money;
      console.log("arrarrarrarr", arr);
      return arr || [];
    },
  },

  mounted() {},

  methods: {
    handleSure() {
      // 预结算
      // <Request>
      //   <deviceIp>172.17.43.202</deviceIp>
      //   <flowId>JWS30320250206081346922</flowId>
      //   <terminalNo>JWS303</terminalNo>
      //   <method>preOpPay</method>
      //   <patientId>3524857</patientId>
      //   <cardNo>{"code":0,"data":{"authNo":"ano3918319059111654401330000","bindAuthCode":null,"birthday":null,"chnlId":null,"defPayChnlId":null,"ecIndexNo":"BC77857304F694912BD4132266256B8E","ecQrCode":null,"ecToken":"330000fecc9ohu4ovv158fab0a0000e4246565","email":null,"gender":null,"idNo":"33048319961120162X","idType":"01","insuOrg":"330483","latlnt":null,"nationality":null,"showCodeType":null,"signCntrNo":null,"signFlag":null,"userName":"闻妙敏"},"message":"成功","orgId":"H33048300173"}</cardNo>
      //   <cardType>29</cardType>
      //   <billNo>032920167,032920176,032920177,032920178,032920179,032920180,032920181,032920182,032920234,032920235,032920236</billNo>
      //   <ybCardNo>33048319961120162X</ybCardNo>
      //   <cash>27542</cash>
      //   <isZj>0</isZj>
      //   <cardHardInfo>{"code":0,"data":{"authNo":"ano3918319059111654401330000","bindAuthCode":null,"birthday":null,"chnlId":null,"defPayChnlId":null,"ecIndexNo":"BC77857304F694912BD4132266256B8E","ecQrCode":null,"ecToken":"330000fecc9ohu4ovv158fab0a0000e4246565","email":null,"gender":null,"idNo":"33048319961120162X","idType":"01","insuOrg":"330483","latlnt":null,"nationality":null,"showCodeType":null,"signCntrNo":null,"signFlag":null,"userName":"闻妙敏"},"message":"成功","orgId":"H33048300173"}</cardHardInfo>
      //   <sourceCode>2</sourceCode>
      //   <deviceVersion>JWS303</deviceVersion>
      //   <deviceInfo>JWS303</deviceInfo>
      //   <operId>JWS303</operId>
      //   <tradeTime>2025-02-06 08:13:46</tradeTime>
      // </Request>	
       const { patientId,cardNo,cardType } = this.patientInfo
      let params = {
        Request: {
          deviceIp: "",
          flowId: "",
          terminalNo: "",
          method: "preOpPay",
          patientId,
          cardNo,
          cardType,
          billNo: '', // 医院待结算单据号
          ybCardNo: '', // 医保卡号
          cash: '',
          isZj: '',
          cardHardInfo: '',
          sourceCode: '',
          deviceVersion: '',
          deviceInfo: '',
          operId: '',
          tradeTime: '',
        },
      };
      let paramsInfo = this.$x2js.js2xml(params);
      buildParent.executeParentMethod(
        "axiosRep",
        paramsInfo,
        "preOpPay"
      );
      // this.$emit("handleSure");
    },
  },
};
</script>

<style scoped lang="scss">
@import "./assets/style";
</style>